package com.winit.template.web;

import com.winit.common.base.BaseController;
import com.winit.common.util.Constants;
import com.winit.template.manager.TemplateManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * Created by wangjian on 2017/9/28.
 */
@RestController
@Api(value = "template", tags = {"template"}, description = "template")
@RequestMapping(value = "/api/v1/template")
public class TemplateController extends BaseController {

    private static Logger logger = LoggerFactory.getLogger(TemplateController.class);

    @Autowired
    TemplateManager templateManager;

    @RequestMapping(value = "/get", method = RequestMethod.GET)
    @ResponseStatus(HttpStatus.OK)
    @ApiOperation(value = "获取所有模版")
    public
    @ResponseBody
    Map get(HttpServletRequest request, HttpServletResponse response) {
        logger.info("com.winit.template.manager.TemplateManager.get");
        Map map = getRtn(Constants.RTN_SUCCESS_CODE, "", templateManager.getTemplateList());
        logger.info("com.winit.template.manager.TemplateManager.get map=" + map);
        return map;
    }

}
